//拿到数据库模块
const db=require('../db');
/*
  引入火热页面爬虫
  */
const theatersCrawler=require('./crawler/theatersCrawler');
const trailersCrawler=require('./crawler/trailersCrawler');
//保存数据到数据库
const saveTheaters=require('./save/saveTheaters');
const saveTrailers=require('./save/saveTrailers');
//上传图片到七牛
const uploadToQiniu=require('./qiniu');

// 获取集合
const Theaters=require('../model/Theaters');
const Trailers=require('../model/Trailers');
/*
*  测试爬虫
*/
(async ()=>{
    // 链接数据库
    await db;
    //  爬取数据
    // const datatheaters = await theatersCrawler();
    const datatrailers = await trailersCrawler();
    // 将爬取的数据保存在数据库中
    // await saveTheaters(datatheaters);
    await saveTrailers(datatrailers);

    //上传图片到七牛 将保存的一部分数据 长传到七牛
    await uploadToQiniu('posterKey',Theaters);
    await uploadToQiniu('coverKey',Trailers);
    await uploadToQiniu('posterKey',Trailers);
    await uploadToQiniu('videoKey',Trailers);
})()